﻿using System;
using DAL;
using VO;
using COMMON;
using System.Collections.Generic;

namespace BLL
{
    public class StatusIncidenciaBLL
    {

        #region Insert
        public static Retorno<StatusIncidencia> Insert(List<StatusIncidencia> obj)
        {
            var objReturn = new Retorno<StatusIncidencia>();
            try
            {
                //Insere incidência
                foreach(var objS in obj)
                {
                    new StatusIncidenciaDAL().Insert(objS);
                }
                objReturn.Error = Enumerator.Error.Success;
                objReturn.Message = "OK";
            }
            catch (Exception ex)
            {
                objReturn.Error = Enumerator.Error.Failed;
                objReturn.Message = ex.Message;
            }
            return objReturn;
        }
        #endregion

        #region Delete
        public static Retorno<StatusIncidencia> Delete(StatusIncidencia obj)
        {
            var objReturn = new Retorno<StatusIncidencia>();
            try
            {
                //Deleta incidência
                new StatusIncidenciaDAL().Delete(obj);
                objReturn.Error = Enumerator.Error.Success;
                objReturn.Message = "OK";
            }
            catch (Exception ex)
            {
                objReturn.Error = Enumerator.Error.Failed;
                objReturn.Message = ex.Message;
            }
            return objReturn;
        }
        #endregion

        #region Select
        public static Retorno<StatusIncidencia> Select(StatusIncidencia obj)
        {
            var objReturn = new Retorno<StatusIncidencia>();
            try
            {
                //Lista Campanha
                objReturn.List = new StatusIncidenciaDAL().Select(obj);
                if (objReturn.List.Count > 0)
                {
                    objReturn.Error = Enumerator.Error.Success;
                    objReturn.Message = "OK";                    
                }
                else
                {
                    objReturn.Error = Enumerator.Error.NoRegistry;
                    objReturn.Message = "Sem registro";
                }
            }
            catch (Exception ex)
            {
                objReturn.Error = Enumerator.Error.Failed;
                objReturn.Message = ex.Message;
            }
            return objReturn;
        }
        #endregion

    }
}